import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    cookies: {},
    debug:false
  },
  mutations: {
    updateCookies(state) {//这里的state对应着上面这个state
      // alert('')
      // this.$Notify.success('全局更新函数cookies')
      var aCookie = document.cookie.split(";");
      var strcookie = [];
      // var re = [];
      // alert(aCookie.length);
      for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (aCrumb[0].toString().trim() == "order_list") {
          continue;
        }
        strcookie.push(aCrumb[0] + " = " + aCrumb[1] + "\n\n");
      }
      // alert(strcookie.length)
      for (let i = 0; i < strcookie.length; i++) {
        const charts = strcookie[i];
        var json = charts.split("=");
        var name = json[0].trim();
        var value = JSON.parse(json[1]);
        // var value = json[1];
        state.cookies[name] = value
      }
      //你还可以在这里执行其他的操作改变state
    },
  },
  actions: {
  },
  modules: {
  }
})
